package com.yulang.common.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yulang.common.pojo.dao.BrandMapper;
import com.yulang.common.pojo.goods.Brand;
import com.yulang.common.pojo.response.CommonResponse;
import com.yulang.common.service.BrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/brand")
public class BrandController {

    @Autowired
    private BrandService service;


    @RequestMapping("/")
    public List<Brand> list(){
        return service.list();
    }

    @RequestMapping("/page")
    public IPage page(Page page){
        return service.page(page);
    }

    @RequestMapping("/add")
    public CommonResponse add(Brand brand){
        service.save(brand);
        return CommonResponse.success();
    }

    @RequestMapping("/update")
    public CommonResponse update(Brand brand){
        service.updateById(brand);
        return CommonResponse.success();
    }

    @RequestMapping("/del/{id}")
    public CommonResponse del(@PathVariable String id){
        service.removeById(id);
        return CommonResponse.success();
    }


}
